Skip to content

fix(e2e): use jq to count DigitalOcean droplets instead of grep#3125

Merged
louisgv merged 1 commit intomainfrom
qa/e2e-fix
Mar 31, 2026
Merged

fix(e2e): use jq to count DigitalOcean droplets instead of grep#3125
louisgv merged 1 commit intomainfrom
qa/e2e-fix

Conversation

@la14-1
Copy link
Copy Markdown
Member

@la14-1 la14-1 commented Mar 31, 2026

Summary

  • The _digitalocean_max_parallel() function used grep -o '"id":[0-9]*' to count existing droplets, but this matched all numeric "id": fields in the JSON response (including nested image, region, and size object IDs), overcounting droplets by ~2x
  • With a 3-droplet account limit and 2 actual droplets, the grepped count returned 4 — making the function think 0 slots were available and failing all 8 DO agents with "No capacity available"
  • Fix: replace grep pattern with jq -r '.droplets | length' which correctly counts only top-level droplet objects

Test Plan

  • Re-ran e2e.sh --cloud digitalocean claude --skip-input-test with the fix — claude PASS (2m 42s)
  • Confirmed jq '.droplets | length' returns 2 (correct) vs grep returning 4 (buggy) for the same API response
  • bash -n syntax check passes on the modified file

-- qa/e2e-tester

Copy link
Copy Markdown
Member

@louisgv louisgv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Security Review

Verdict: APPROVED
Commit: 15f8171

Findings

No security issues found. This change improves correctness by replacing grep-based ID counting with proper JSON parsing via jq -r '.droplets | length'.

Improvements:

  • Old approach counted all "id": occurrences (could match unrelated IDs)
  • New approach specifically counts the .droplets array length
  • Both have proper error fallback (|| { printf '3'; return 0; })
  • jq is already a known dependency (used 6+ times in this file)

Tests

  • bash -n: PASS
  • bun test: PASS (2030 tests, 0 failures)
  • curl|bash safety: N/A (internal E2E script)
  • macOS compat: OK (jq works identically across platforms)

Security Checks

  • ✅ Command injection: No untrusted input to jq
  • ✅ Credential leaks: Token handled via temp config file (chmod 600)
  • ✅ Error handling: Proper fallback on jq failure
  • ✅ Dependency availability: jq already widely used in this file

-- security/pr-reviewer

@louisgv louisgv added the security-approved Security review approved label Mar 31, 2026
The previous grep -o '"id":[0-9]*' pattern matched all numeric id fields
in the droplets JSON response (including nested image/region/size ids),
overcounting droplets by 2x and falsely reporting quota exhaustion.

Replace with jq '.droplets | length' which correctly counts only top-level
droplet objects. This restores DigitalOcean capacity detection so e2e runs
can use available droplet slots.

-- qa/e2e-tester
@louisgv louisgv merged commit e98a3a5 into main Mar 31, 2026
5 checks passed
@louisgv louisgv deleted the qa/e2e-fix branch March 31, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

security-approved Security review approved

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants